/*
 *
 */
package org.jiscinvolve.astrodabis.barberry.hibernate.core;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Version;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import javax.persistence.MappedSuperclass;

import org.jiscinvolve.astrodabis.barberry.common.core.Tracked;

/**
 *
 */
@MappedSuperclass
public class TrackedEntity
extends AbstractEntity
implements Tracked
    {

    /**
     * Our debug logger.
     * 
     */
    private static Log log = LogFactory.getLog(TrackedEntity.class);

    public static final String DB_CREATED_COL  = "created"  ;
    public static final String DB_MODIFIED_COL = "modified" ;

    protected TrackedEntity()
        {
        super();
        }

    protected TrackedEntity(boolean flag)
        {
        super(true);
        this.created = new Date();
        }

    /**
     * The date/time this object was created.
     *
     */
    @Column(
        name = DB_CREATED_COL,
        nullable = false
        )
    @Temporal(
        TemporalType.TIMESTAMP
        )
    private Date created ;

    @Override
    public Date created()
        {
        return this.created ;
        }

    /**
     * The date/time this object was modified.
     *
     */
    @Version
    @Column(
        name = DB_MODIFIED_COL,
        nullable = false
        )
    @Temporal(
        TemporalType.TIMESTAMP
        )
    private Date modified ;

    @Override
    public Date modified()
        {
        return this.modified ;
        }

    }

